package com.semeureka.fault.dao.impl;

import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.semeureka.fault.bean.Point;
import com.semeureka.fault.dao.PointDao;

@Component
public class PointDaoImpl implements PointDao {
	@Autowired
	private SessionFactory sessionFactory;

	@Override
	public Point findByTypeValue(Integer type, byte[] value) {
		return (Point) sessionFactory.getCurrentSession().createCriteria(Point.class)
				.add(Restrictions.eq("type", type)).add(Restrictions.eq("value", value))
				.uniqueResult();
	}
}
